package io.scnb.lesson001.demo3;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.lang.Nullable;

public class UserFactoryBean implements FactoryBean {

    int count = 1;

    @Nullable
    @Override
    public Object getObject() throws Exception {
        UserModel userModel = new UserModel();
        userModel.setName("我是通过FactoryBean创建的第" + count++ + "对象");
        return userModel;
    }

    @Override
    public Class<?> getObjectType() {
        return UserModel.class;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }
}
